﻿using System;
namespace Moonlite.Services.CodeCompletion
{
    public class AndromedaObjectWithSpecificChildren : AndromedaObject
    {
        private AndromedaObjectClassCollection classes = new AndromedaObjectClassCollection();
        public AndromedaObjectClassCollection Classes
        {
            get { return classes; }
        }

        private AndromedaObjectEnrichmentCollection enrichments = new AndromedaObjectEnrichmentCollection();
        public AndromedaObjectEnrichmentCollection Enrichments
        {
            get { return enrichments; }
        }

        private AndromedaObjectFieldCollection fields = new AndromedaObjectFieldCollection();
        public AndromedaObjectFieldCollection Fields
        {
            get { return fields; }
        }

        private AndromedaObjectMethodCollection methods = new AndromedaObjectMethodCollection();
        public AndromedaObjectMethodCollection Methods
        {
            get { return methods; }
        }

        private AndromedaObjectPropertyCollection properties = new AndromedaObjectPropertyCollection();
        public AndromedaObjectPropertyCollection Properties
        {
            get { return properties; }
        }

        private AndromedaObjectStructCollection structs = new AndromedaObjectStructCollection();
        public AndromedaObjectStructCollection Structs
        {
            get { return structs; }
        }

        public virtual AndromedaObjectClassCollection GetAllClasses()
        {
            AndromedaObjectClassCollection objects = new AndromedaObjectClassCollection();
            objects.AddRange(Classes);
            foreach (AndromedaObject @object in Children)
            {
                if (@object is AndromedaObjectWithSpecificChildren)
                {
                    objects.AddRange(((AndromedaObjectWithSpecificChildren)@object).GetAllClasses());
                }
            }

            return objects;
        }

        public virtual AndromedaObjectEnrichmentCollection GetAllEnrichments()
        {
            AndromedaObjectEnrichmentCollection objects = new AndromedaObjectEnrichmentCollection();
            objects.AddRange(Enrichments);
            foreach (AndromedaObject @object in Children)
            {
                if (@object is AndromedaObjectWithSpecificChildren)
                {
                    objects.AddRange(((AndromedaObjectWithSpecificChildren)@object).GetAllEnrichments());
                }
            }

            return objects;
        }

        public virtual AndromedaObjectFieldCollection GetAllFields()
        {
            AndromedaObjectFieldCollection objects = new AndromedaObjectFieldCollection();
            objects.AddRange(Fields);
            foreach (AndromedaObject @object in Children)
            {
                if (@object is AndromedaObjectWithSpecificChildren)
                {
                    objects.AddRange(((AndromedaObjectWithSpecificChildren)@object).GetAllFields());
                }
            }

            return objects;
        }

        public virtual AndromedaObjectMethodCollection GetAllMethods()
        {
            AndromedaObjectMethodCollection objects = new AndromedaObjectMethodCollection();
            objects.AddRange(Methods);
            foreach (AndromedaObject @object in Children)
            {
                if (@object is AndromedaObjectWithSpecificChildren)
                {
                    objects.AddRange(((AndromedaObjectWithSpecificChildren)@object).GetAllMethods());
                }
            }

            return objects;
        }

        public virtual AndromedaObjectPropertyCollection GetAllProperties()
        {
            AndromedaObjectPropertyCollection objects = new AndromedaObjectPropertyCollection();
            objects.AddRange(Properties);
            foreach (AndromedaObject @object in Children)
            {
                if (@object is AndromedaObjectWithSpecificChildren)
                {
                    objects.AddRange(((AndromedaObjectWithSpecificChildren)@object).GetAllProperties());
                }
            }

            return objects;
        }

        public virtual AndromedaObjectStructCollection GetAllStructs()
        {
            AndromedaObjectStructCollection objects = new AndromedaObjectStructCollection();
            objects.AddRange(Structs);
            foreach (AndromedaObject @object in Children)
            {
                if (@object is AndromedaObjectWithSpecificChildren)
                {
                    objects.AddRange(((AndromedaObjectWithSpecificChildren)@object).GetAllStructs());
                }
            }

            return objects;
        }

        public AndromedaObjectWithSpecificChildren()
            : this(null)
        {
        }

        public AndromedaObjectWithSpecificChildren(AndromedaObject parent)
        {
            Parent = parent;
        }
    }
}
